﻿using System;
using System.Collections.Generic;

namespace Hsp.Auto.Interface
{
    public interface IDbHelper
    {
        /// <summary>
        /// 泛型方法查询数据实体
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="id">id</param>
        /// <returns></returns>
        T SingleQuery<T>(int id);

        /// <summary>
        /// 泛型方法查询数据实体
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="id">数据库脚本</param>
        /// <returns></returns>
        T SingleQuery<T>(string id);

        /// <summary>
        /// 泛型方法查询数据实体
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="id">数据库脚本</param>
        /// <returns></returns>
        T SingleQuery<T>(Guid id);

        /// <summary>
        /// 泛型方法根据查询条件查询数据实体
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="sqlwhere">查询条件</param>
        /// <returns></returns>
        T SingleWhereQuery<T>(string sqlwhere);

        /// <summary>
        /// 泛型方法查询数据列表
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <returns></returns>
        List<T> ListQuery<T>();

        /// <summary>
        /// 泛型方法查询数据列表
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="strSql">数据库脚本</param>
        /// <returns></returns>
        List<T> ListQuery<T>(string strSql);

        /// <summary>
        /// 泛型数据库实体插入
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        int Add<T>(T t);

        /// <summary>
        /// 泛型数据库实体删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        int Delete<T>(int id);

        /// <summary>
        /// 根据查询条件删除数据
        /// </summary>
        /// <typeparam name="T">泛型</typeparam>
        /// <param name="sqlwhere">查询条件</param>
        /// <returns></returns>
        int DeleteByWhereSql<T>(string sqlwhere);

        /// <summary>
        /// 泛型数据库实体更新
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        int Update<T>(T t);
    }
}
